// https://umijs.org/config/
import {defineConfig} from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';

const {REACT_APP_ENV} = process.env;
// export const DoMain: string = "/thinkback/";
export const DoMain: string = "/back/";
export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  // base: "/thinkback/",
  base: "/back/",
  // publicPath: "/thinkback/",
  publicPath: "/back/",
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  routes: [
    {
      path: '/',
      component: '../layouts/SecurityLayout',
      routes: [
        {
          path: '/user/login',
          component: './user/login',
        },
        {
          path: '/',
          component: '../layouts/TabHeaderLayout',
          routes: [
            {
              path: '/',
              redirect: '/dashboard',
            },
            {
              name: 'Dashboard',
              icon: 'home',
              path: '/dashboard',
              component: './DashboardWorkplace',
            },
            {
              path: '/teaching',
              name: 'teaching',
              icon: 'insertRowAbove',
              authority: ['ROLE_ADMIN', 'ROLE_TEACHING', "ROLE_COURSE", "ROLE_TESTING", "ROLE_CHECK", "ROLE_STAT", "ROLE_COMMENT"],
              routes: [
                {
                  name: 'course',
                  icon: 'table',
                  path: '/teaching/course',
                  authority: ['ROLE_ADMIN', 'ROLE_COURSE', 'ROLE_TEACHING'],
                  component: '../layouts/CourseGroupHeaderLayout',
                  routes: [
                    {
                      component: './teaching/course/CourseListPage',
                      path: '/teaching/course/list',
                    },
                    {
                      component: './teaching/course/CreateNewCourse',
                      path: '/teaching/course/create',
                    },
                    {
                      component: './teaching/course/CourseExamine',
                      path: '/teaching/course/examine',
                    },
                    {
                      component: './teaching/course/VRCourseEditor',
                      path: '/teaching/course/lesson',
                    },
                    {
                      component: './teaching/course/TemplateManager',
                      path: '/teaching/course/templete',
                    },
                    {
                      component: './teaching/course/TypeManager',
                      path: '/teaching/course/type',
                    },
                    {
                      component: './teaching/course/TagManager',
                      path: '/teaching/course/tag',
                    },
                    {
                      component: './teaching/course/ComponentManager',
                      path: '/teaching/course/component',
                    },
                    {
                      component: './teaching/course/CourseAssetManager',
                      path: '/teaching/course/assets',
                    },
                  ],
                },
                {
                  path: '/teaching/test/goExam/testing',
                  component: './teaching/test/GoExamTesting',
                },
                {
                  name: 'exam',
                  icon: 'smile',
                  path: '/teaching/exam',
                  authority: ['ROLE_ADMIN', 'ROLE_TESTING', 'ROLE_TEACHING'],
                  component: '../layouts/ExamGroupHeaderLayout',
                  routes: [
                    {
                      path: '/teaching/exam/test',
                      component: './teaching/test/TestManager',
                    },
                    {
                      path: '/teaching/exam/paper',
                      component: './teaching/test/PaperManager',
                    },
                    {
                      path: '/teaching/exam/paperDetailes',
                      component: './teaching/test/PaperDetailes',
                    },
                    {
                      path: '/teaching/exam/editor',
                      component: './teaching/test/PaperEditor',
                    },
                    {
                      path: '/teaching/exam/question',
                      component: './teaching/test/QuestionManager',
                    },
                    {
                      path: '/teaching/exam/viewQuestion',
                      component: './teaching/test/ViewQuestion',
                    },
                    {
                      path: '/teaching/exam/newQuestion',
                      component: './teaching/test/CreateNewQuestion',
                    },
                    {
                      path: '/teaching/exam/training',
                      component: './teaching/test/TrainingManager',
                    },
                    {
                      path: '/teaching/exam/checkPointer',
                      component: './teaching/test/CheckPointer',
                    },
                    {
                      path: '/teaching/exam/tags',
                      component: './teaching/test/TagsManager',
                    },
                    {
                      path: '/teaching/exam/type',
                      component: './teaching/test/TypeManager',
                    },
                  ],
                },
                {
                  name: 'check',
                  icon: 'smile',
                  authority: ['ROLE_ADMIN', 'ROLE_CHECK', 'ROLE_TEACHING'],
                  path: '/teaching/check',
                  component: '../layouts/CheckGroupHeaderLayout',
                  routes: [
                    {
                      component: './teaching/check/ExamCheckManager',
                      path: '/teaching/check/exam',
                    },
                    {
                      component: './teaching/check/ExamCheckStudents',
                      path: '/teaching/check/students',
                    },
                    {
                      component: './teaching/check/TrainingCheckManager',
                      path: '/teaching/check/training',
                    },
                    {
                      component: './teaching/check/StudentsTestPaper',
                      path: '/teaching/check/studentsTestPaper',
                    },
                  ],
                },
                {
                  name: 'stat',
                  icon: 'smile',
                  authority: ['ROLE_ADMIN', 'ROLE_STAT', 'ROLE_TEACHING'],
                  path: '/teaching/stat',
                  component: '../layouts/LearnStatLayout',
                  routes: [
                    {
                      path: '/teaching/stat/exp',
                      component: './teaching/stat/ExpStat',
                    },
                    {
                      path: '/teaching/stat/course',
                      component: './teaching/stat/CourseStat',
                    },
                    {
                      path: '/teaching/stat/student',
                      component: './teaching/stat/StudentStat',
                    },
                    {
                      path: '/teaching/stat/exam',
                      component: './teaching/stat/ExamStat',
                    },
                    {
                      path: '/teaching/stat/training',
                      component: './teaching/stat/TrainingStat',
                    },
                  ],
                },
                {
                  name: 'comment',
                  icon: 'smile',
                  path: '/teaching/comment',
                  authority: ["ROLE_ADMIN", "ROLE_COMMENT", 'ROLE_TEACHING'],
                  component: './teaching/commentPage',
                },
                // {
                //   name: 'teach',
                //   icon: 'smile',
                //   path: '/teaching/teach',
                //   component: './todo',
                // },
              ],
            },
            {
              name: 'orgs',
              icon: 'apartment',
              path: '/orgs',
              component: '../layouts/SecurityLayout',
              authority: ['ROLE_ADMIN', 'ROLE_ORGNIZATION', "ROLE_SCHOOL", "ROLE_COLLEGE", "ROLE_MAJOR", "ROLE_CLASS", "ROLE_TEACHER", "ROLE_STUDENT"],
              routes: [
                {
                  name: 'school',
                  icon: 'smile',
                  path: '/orgs/school',
                  authority: ["ROLE_ADMIN", "ROLE_SCHOOL", 'ROLE_ORGNIZATION'],

                  component: './orgs/school/SchoolManagerPage',
                },
                {
                  name: 'college',
                  icon: 'smile',
                  path: '/orgs/college',
                  authority: ["ROLE_ADMIN", "ROLE_COLLEGE", 'ROLE_ORGNIZATION'],

                  component: './orgs/college/CollegeManagerPage',
                },
                {
                  name: 'major',
                  icon: 'smile',
                  path: '/orgs/major',
                  authority: ["ROLE_ADMIN", "ROLE_MAJOR", 'ROLE_ORGNIZATION'],

                  component: './orgs/major/MajorManagerPage',
                },
                {
                  name: 'class',
                  icon: 'smile',
                  path: '/orgs/class',
                  authority: ["ROLE_ADMIN", "ROLE_CLASS", 'ROLE_ORGNIZATION'],

                  component: './orgs/class/ClassManagerPage',
                },
                {
                  path: '/orgs/classD',
                  authority: ["ROLE_ADMIN", "ROLE_CLASS", 'ROLE_ORGNIZATION'],

                  component: './orgs/class/ClassDetailes',
                },

                {
                  name: 'student',
                  icon: 'table',
                  path: '/orgs/student',
                  authority: ["ROLE_ADMIN", "ROLE_STUDENT", 'ROLE_ORGNIZATION'],

                  component: './orgs/student/StudentManagerPage',
                },
                {
                  name: 'teacher',
                  icon: 'table',
                  path: '/orgs/teacher',
                  authority: ["ROLE_ADMIN", "ROLE_TEACHER", 'ROLE_ORGNIZATION'],

                  component: './orgs/teacher/TeacherManagerPage',
                },
              ],
            },
            {
              path: '/asset',
              name: 'assets',
              icon: 'folderOpen',
              component: '../layouts/AssetsGroupHeaderLayout',
              routes: [
                {
                  icon: 'smile',
                  path: '/asset/list',
                  component: './assets/AssetManagerPage',
                },
                {
                  path: '/asset/create',
                  component: './assets/AssetUploadPage',
                },
              ],
            },
            {
              path: '/platform',
              name: 'platform',
              icon: 'ClusterOutlined',
              component: '../layouts/PlatformGroupHeaderLayout',
              routes: [
                {
                  icon: 'smile',
                  path: '/platform/list',
                  component: './platform/PlatformManagerPage',
                },
                /*   {
                    icon: 'smile',
                    path: '/platform/list',
                    component: './platform/PlatformManagerPage',
                  },
                  {
                    path: '/platform/create',
                    component: './platform/PlatformUploadPage',
                  }, */
              ],
            },
            {
              path: '/article',
              name: 'article',
              authority: ['ROLE_ADMIN', 'ROLE_ARTICLE'],
              icon: 'fileText',
              component: '../layouts/ArticleGroupHeaderLayout',
              routes: [
                {
                  icon: 'smile',
                  path: '/article/list',
                  component: './article/ArticleManagerPage',
                },
                {
                  path: '/article/create',
                  component: './article/CreateArticle',
                },
                {
                  path: '/article/update',
                  component: './article/CreateArticle',
                },
                {
                  path: '/article/show',
                  component: './article/ArticleShowPage',
                },
                {
                  path: '/article/type',
                  component: './article/ArticleTypePage',
                },
                {
                  path: '/article/tag',
                  component: './article/ArticleTagPage',//NewsManagerPage
                }
              ],
            },
            {
              path: '/news',
              name: 'news',
              authority: ['ROLE_ADMIN', 'ROLE_NEWS'],
              icon: 'inbox',
              component: '../layouts/NewsGroupHeaderLayout',
              routes: [
                {
                  icon: 'smile',
                  path: '/news/list',
                  component: './news/NewsManagerPage',
                },
                {
                  path: '/news/create',
                  component: './news/CreateNews',
                },
                {
                  path: '/news/update',
                  component: './news/CreateNews',
                },
                {
                  path: '/news/show',
                  component: './news/NewsShowPage',
                },
                {
                  path: '/news/type',
                  component: './news/NewsTypePage',
                },
                {
                  path: '/news/tag',
                  component: './news/NewsTagPage',//NewsManagerPage
                }
              ],
            },
            {
              path: '/user',
              name: 'user.center',
              icon: 'user',
              // component: './Admin',
              // authority: ['admin'],
              authority: ['ROLE_ADMIN', 'ROLE_ACCOUNT', "ROLE_USER", "ROLE_ROLE", "ROLE_PERMISSION"],
              routes: [
                {
                  name: 'users',
                  icon: 'table',
                  path: '/user/users',
                  authority: ['ROLE_ADMIN', 'ROLE_USER', 'ROLE_ACCOUNT'],
                  component: './account/UserlistPage',
                },
                {
                  name: 'role',
                  icon: 'table',
                  path: '/user/role',
                  authority: ['ROLE_ADMIN', 'ROLE_ROLE', 'ROLE_ACCOUNT'],
                  component: './account/RolelistPage',
                },
                {
                  name: 'permission',
                  icon: 'table',
                  path: '/user/permission',
                  authority: ['ROLE_ADMIN', 'ROLE_PERMISSION', 'ROLE_ACCOUNT'],
                  component: './account/PermissionPage',
                },
              ],
            },
            {
              path: '/website',
              authority: ['ROLE_ADMIN', 'ROLE_WEBSITE'],
              name: 'website.center',
              icon: 'database',
              component: './website',
            },
            {
              path: '/account',
              name: 'account.center',
              icon: 'user',
              component: './Admin',
              authority: ['admin'],
            },
            {
              component: './404',
            },
          ],
        },
        {
          component: './404',
        },
      ],
    },
    {
      component: './404',
    },
  ],
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
});
